﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="EditPackage.aspx.cs" Inherits="Admin_Package_EditPackage" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <div class="box">
        <asp:HiddenField ID="hiddID" runat="server" />
        <h2>Sender Info</h2>
        <asp:Panel runat="server" ID="panelNonMemberInfo" Style="display: block;" CssClass="form">
            <div class="oneline">
                <asp:TextBox ID="txtName" runat="server" SkinID="mediumTextBox"></asp:TextBox>
                <asp:TextBoxWatermarkExtender ID="txtName_TextBoxWatermarkExtender" runat="server" Enabled="True" TargetControlID="txtName" WatermarkCssClass="watermarked" WatermarkText="Name">
                </asp:TextBoxWatermarkExtender>
                <%--<label>Name</label>--%>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName" ErrorMessage="*"></asp:RequiredFieldValidator>
            </div>

            <div class="oneline">
                <asp:TextBox ID="txtEmail" runat="server" SkinID="mediumTextBox"></asp:TextBox>
                <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" runat="server" Enabled="True" TargetControlID="txtEmail" WatermarkCssClass="watermarked" WatermarkText="Email">
                </asp:TextBoxWatermarkExtender>
                <%--<label>Email</label>--%>
            </div>
            <div class="oneline">
                <asp:TextBox ID="txtNRIC" runat="server" SkinID="mediumTextBox"></asp:TextBox>
                <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender3" runat="server" Enabled="True" TargetControlID="txtNRIC" WatermarkCssClass="watermarked" WatermarkText="NRIC">
                </asp:TextBoxWatermarkExtender>
                <%--<label>NRIC</label>--%>
            </div>

            <div class="oneline">
                <asp:TextBox ID="txtContact" runat="server" SkinID="mediumTextBox"></asp:TextBox>
                <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender4" runat="server" Enabled="True" TargetControlID="txtContact" WatermarkCssClass="watermarked" WatermarkText="Contact Number">
                </asp:TextBoxWatermarkExtender>
                <%--<label>Contact</label>--%>
            </div>

            <div class="oneline">
                <asp:TextBox ID="txtBlock" runat="server" SkinID="mediumTextBox"></asp:TextBox>
                <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="txtBlock" WatermarkText="Unit &amp; Block" WatermarkCssClass="watermarked"></asp:TextBoxWatermarkExtender>
                <asp:TextBox ID="txtStreet" runat="server" SkinID="mediumTextBox"></asp:TextBox>
                <asp:TextBoxWatermarkExtender ID="TextStreet_TextBoxWatermarkExtender" runat="server" Enabled="True" TargetControlID="txtStreet" WatermarkCssClass="watermarked" WatermarkText="Street">
                </asp:TextBoxWatermarkExtender>
                <asp:TextBox ID="txtCity" runat="server" SkinID="mediumTextBox"></asp:TextBox>
                <asp:TextBoxWatermarkExtender ID="TextCity_TextBoxWatermarkExtender" runat="server" Enabled="True" TargetControlID="txtCity" WatermarkCssClass="watermarked" WatermarkText="City">
                </asp:TextBoxWatermarkExtender>
                <asp:TextBox ID="txtProvince" runat="server" SkinID="mediumTextBox"></asp:TextBox>
                <asp:TextBoxWatermarkExtender ID="TextProvince_TextBoxWatermarkExtender" runat="server" Enabled="True" TargetControlID="txtProvince" WatermarkCssClass="watermarked" WatermarkText="Province">
                </asp:TextBoxWatermarkExtender>
                <asp:DropDownList ID="ddlCountry" runat="server" Style="width: 100px;"></asp:DropDownList>
                <%--<label>Address</label>--%>
            </div>
        </asp:Panel>
    </div>

    <asp:Panel runat="server" ID="panelReceiver" CssClass="box form">
        <h2>Receiver</h2>
        <div class="oneline">
            <asp:TextBox ID="txtReName" runat="server" SkinID="mediumTextBox"></asp:TextBox>
            <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender9" runat="server" TargetControlID="txtReName" WatermarkText="Name" WatermarkCssClass="watermarked"></asp:TextBoxWatermarkExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtReName" ErrorMessage="*"></asp:RequiredFieldValidator>
            <%--<label>Name</label>--%>
        </div>
        <div class="oneline">
            <asp:TextBox ID="txtReContact" runat="server" SkinID="mediumTextBox"></asp:TextBox>
            <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender10" runat="server" TargetControlID="txtReContact" WatermarkText="Contact" WatermarkCssClass="watermarked"></asp:TextBoxWatermarkExtender>
        </div>
        <div class="oneline">

            <asp:TextBox ID="txtReBlock" runat="server" SkinID="mediumTextBox"></asp:TextBox>
            <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender5" runat="server" TargetControlID="txtReBlock" WatermarkText="Unit &amp; Block" WatermarkCssClass="watermarked"></asp:TextBoxWatermarkExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtReBlock" ErrorMessage="*"></asp:RequiredFieldValidator>
            <asp:TextBox ID="txtReStreet" runat="server" SkinID="mediumTextBox"></asp:TextBox>
            <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender6" runat="server" Enabled="True" TargetControlID="txtReStreet" WatermarkCssClass="watermarked" WatermarkText="Street">
            </asp:TextBoxWatermarkExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtReStreet" ErrorMessage="*"></asp:RequiredFieldValidator>
            <asp:TextBox ID="txtReCity" runat="server" SkinID="mediumTextBox"></asp:TextBox>
            <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender7" runat="server" Enabled="True" TargetControlID="txtReCity" WatermarkCssClass="watermarked" WatermarkText="City">
            </asp:TextBoxWatermarkExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtReCity" ErrorMessage="*"></asp:RequiredFieldValidator>
            <asp:TextBox ID="txtReProvince" runat="server" SkinID="mediumTextBox"></asp:TextBox>
            <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender8" runat="server" Enabled="True" TargetControlID="txtReProvince" WatermarkCssClass="watermarked" WatermarkText="Province">
            </asp:TextBoxWatermarkExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtReProvince" ErrorMessage="*"></asp:RequiredFieldValidator>
            <asp:DropDownList ID="ddlReCountry" runat="server" Style="width: 100px;"></asp:DropDownList>
            <%--<label>Address</label>--%>
        </div>
    </asp:Panel>

    <asp:Panel runat="server" ID="panelPackageInfo" CssClass="form box">
        <h2>Package Info</h2>

        <div class="oneline">
            <asp:DropDownList ID="ddlParcelType" runat="server">
            </asp:DropDownList>
            <label>ParcelType</label>
        </div>
        <div class="oneline">
            <asp:DropDownList ID="ddlFragile" runat="server">
                <asp:ListItem Value="True">Yes</asp:ListItem>
                <asp:ListItem Value="False">No</asp:ListItem>
            </asp:DropDownList>
            <label>Fragile</label>
        </div>

        <div class="oneline">
            <asp:TextBox ID="txtWeight" runat="server" Text="0"></asp:TextBox>
            <label>Weight</label>
                 <br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                        ControlToValidate="txtWeight" ErrorMessage="*Please fill in the weight" 
                        ForeColor="Red" Display="Dynamic" ></asp:RequiredFieldValidator>
                        
                    <asp:CompareValidator id="CompareFieldValidator1" runat="server"
        ControlToValidate="txtWeight"
        ValueToCompare="0"
        Type="Double"
        Operator="GreaterThan"
        ErrorMessage="*Weight cannot be 0." ForeColor="Red" Display="Dynamic"></asp:CompareValidator >
        </div>

        <div class="oneline">
            <div class="name">Status</div>
            <asp:DropDownList ID="ddlStatus" runat="server">
            </asp:DropDownList>
        </div>
    </asp:Panel>

    <asp:UpdatePanel ID="panelRoute" runat="server">
        <ContentTemplate>
            <div class="box_simple">
                <h2>Edit Route</h2>
                <div class="oneline">
                    <br />
                    <asp:GridView ID="gvTransit" runat="server" AutoGenerateColumns="False" Width="100%" GridLines="None" CellPadding="2" ForeColor="Black"
                        OnRowCommand="gvTransit_RowCommand" OnRowEditing="gvTransit_RowEditing" OnRowCancelingEdit="gvTransit_RowCancelingEdit" OnRowUpdating="gvTransit_RowUpdating" OnRowDeleting="gvTransit_RowDeleting" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px">
                        <AlternatingRowStyle BackColor="PaleGoldenrod" />
                        <Columns>
                            <asp:TemplateField HeaderText="Branch">
                                <ItemTemplate>
                                    <asp:Label ID="lblBranchName" runat="server" Text='<%# Bind("CurrentBranch") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="ddlBranch" runat="server" DataSource='<%# lstBranch %>' DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("CurrentBranchID") %>'>
                                    </asp:DropDownList>
                                    <asp:HiddenField ID="hidID" runat="server" Value='<%# Eval("TransitID") %>' />
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Address" ItemStyle-Width="600px">
                                <ItemTemplate>
                                    <asp:Label ID="lblAddress" runat="server" Text='<%# Eval("CurrentAddress") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle Width="400px"></ItemStyle>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Status">
                                <ItemTemplate>
                                    <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("Status").ToString()=="1" ? "Arrived" : "Pending" %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField ShowEditButton="True" ItemStyle-Width="50px">
                                <ItemStyle Width="50px" />
                            </asp:CommandField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="btnAdd" runat="server" CausesValidation="false" CommandArgument='<%# Eval("TransitID") %>' CommandName="AddTransit" Text="Add Below"></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="btnDelete" CausesValidation="false" runat="server" Visible='<%# Eval("TransitID").ToString() == first_transitid.ToString() ? false : true %>' CommandArgument='<%# Eval("TransitID") %>' CommandName="DelTransit" Text="Delete" OnClientClick="return confirm('Do you confirm to delete?')"></asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>

                        <FooterStyle BackColor="Tan" />
                        <HeaderStyle BackColor="Tan" Font-Bold="True" />
                        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                        <RowStyle CssClass="gvTr" />
                        <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />

                        <SortedAscendingCellStyle BackColor="#FAFAE7" />
                        <SortedAscendingHeaderStyle BackColor="#DAC09E" />
                        <SortedDescendingCellStyle BackColor="#E1DB9C" />
                        <SortedDescendingHeaderStyle BackColor="#C2A47B" />

                    </asp:GridView>
                    <br />
                    <asp:Panel ID="panelNew" runat="server" class="box_simple" Visible="false">
                        <div class="oneline">
                            <div class="oneline">
                                <div class="name">
                                    Current Branch:
                                    <asp:Label ID="lblCurrentBranchName" runat="server"></asp:Label>
                                </div>

                            </div>
                            <table style="width: 100%;" cellpadding="1" cellspacing="2">
                                <tr>
                                    <td>
                                        <asp:DropDownList ID="ddlBranch" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlBranch_SelectedIndexChanged">
                                        </asp:DropDownList></td>
                                    <td style="width: 60%">
                                        <asp:Label ID="lblBranchAddress" runat="server"></asp:Label>
                                        <asp:Label ID="lblBranchCountry" runat="server"></asp:Label>
                                    </td>
                                    <td style="width: 10%"></td>
                                </tr>
                            </table>
                            <asp:HiddenField ID="hidCurrentTransit" runat="server" />
                            <div style="margin: 10px;">
                                <asp:LinkButton ID="btnSubmit" runat="server" Text="Submit" CausesValidation="false" OnClick="btnSubmit_Click"></asp:LinkButton>
                                <span style="padding: 0 10px;"></span>
                                <asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click"></asp:LinkButton>
                            </div>
                            <div style="margin: 10px;">
                            </div>
                        </div>
                    </asp:Panel>
                    <br />
                </div>
            </div>
        </ContentTemplate>

    </asp:UpdatePanel>


    <asp:Button ID="btnSave" runat="server" Text="  Save  " OnClick="btnSave_Click" />

</asp:Content>

